process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'

import path from "path";
import {app, session} from 'electron'
import MainController from './main/main-controller'
import TrayController from './main/tray-controller'


let mainWindow, tray

function createWindow () {
  /**
   * Initial window options
   */
  mainWindow = new MainController()
  tray = new TrayController(mainWindow)

  if (process.env.DEBUGGING) {
    // if on DEV or Production with debug enabled
    mainWindow.Window.webContents.openDevTools()
    session.defaultSession.loadExtension(path.resolve(__dirname,'../plugin/vue-devtool'))
  } else {
    // we're on production; no access to devtools pls
    mainWindow.Window.webContents.on('devtools-opened', () => {
      mainWindow.webContents.closeDevTools()
    })
  }
}

app.on('ready', createWindow)

app.on('activate', () => {
  if (mainWindow === null) {
    createWindow()
  }
})
